<template>
	<view>
		<view class="top flex justify-center align-end">
			<view class="top_info flex flex-column justify-around align-center py-2">
				<image src="../../static/image/my/1596101529570.jpg" mode="" class="rounded-50"></image>
				<p class="h3">{{ currentFactoryInfo.factoryName || currentFactoryInfo.name}}</p>

				<view class="flex content-center align-center">
					<p class="h5">
						企业邀请码：
						<span>{{ currentFactoryInfo.sfactoryNo }}</span>
					</p>
					<span @click="copyCode" class="yby_btn py-1 px-2">复制</span>
				</view>
			</view>
		</view>
		<uni-list>
			<!-- <uni-list-item @click="open" title="版本检测"></uni-list-item> -->
			<uni-list-item thumb="../../static/image/my/aboutUs.png" @click="aboutUs('aboutUs')" title="关于我们"></uni-list-item>
			<uni-list-item thumb="../../static/image/my/shouce.png" @click="aboutUs('direction')" title="操作手册"></uni-list-item>
			<uni-list-item thumb="../../static/image/my/yijian.png" @click="aboutUs('suggestion')" title="意见反馈"></uni-list-item>
			<uni-list-item thumb="../../static/image/my/zhgl.png" v-if="admin" @click="aboutUs('accountManagement')" title="账号管理"></uni-list-item>
			<uni-list-item thumb="../../static/image/my/out.png" @click="outLogin" title="退出登录"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
	data() {
		return {
			currentFactoryInfo: {},
			admin: 0
		};
	},
	onLoad() {
		let user = uni.getStorageSync('userInfo');
		this.admin = user.isadmin;
		if (uni.getStorageSync('factoryinfo')) {
			this.currentFactoryInfo = uni.getStorageSync('factoryinfo');
			// console.log(this.currentFactoryInfo);
		}
	},
	methods: {
		outLogin() {
			uni.showModal({
				title: '提示',
				content: '确定要退出登录吗？',
				success: res => {
					if (res.confirm) {
						uni.removeStorageSync('token');
						uni.removeStorageSync('userInfo');
						uni.removeStorageSync('factoryinfo');
						uni.reLaunch({
							url: '/pages/login/login'
						});
					} else if (res.cancel) {
						// console.log('用户点击取消');
					}
				}
			});
		},
		// 复制邀请码
		copyCode() {
			uni.setClipboardData({
				data: this.currentFactoryInfo.sfactoryNo,
				success: function() {
					// console.log('success');
				}
			});
		},
		// 关于我们
		aboutUs(name) {
			uni.navigateTo({
				url: `../my/${name}`
			});
		},
		/**
		 * 点击确认按钮触发
		 * @param {Object} done
		 * @param {Object} value
		 */
		confirm(done, value) {
			// 输入框的值
			// console.log(value);
			// TODO 做一些其他的事情，手动执行 done 才会关闭对话框
			// ...
			// done()
		}
	}
};
</script>

<style lang="scss">
.top {
	width: 100%;
	height: 400rpx;
	background: linear-gradient(to right, #99bdff, #5880ff);
	.top_info {
		width: 680rpx;
		height: 320rpx;
		background-image: url(../../static/image/my/my_top3@2x.png);
		background-size: 100% 100%;
		image {
			width: 110rpx;
			height: 110rpx;
		}
		.yby_btn {
			border: 1rpx solid #000;
			border-radius: 36rpx;
			margin-left: 10rpx;
		}
	}
}


</style>
